package com.ruoyi.web.controller.gym;

import com.ny.domain.CourseScheduleDO;
import com.ny.domain.EmployeeDO;
import com.ny.dto.CourseScheduleDTO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.EmployeeDTO;
import com.ny.dto.RestResult;
import com.ny.dto.UpdateGroup;
import com.ny.query.CourseScheduleQuery;
import com.ny.query.EmployeeQuery;
import com.ny.query.QueryGroup;
import com.ny.service.EmployeeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 员工管理
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("员工管理")
@RequestMapping("employee")
@RestController
public class EmployeeController extends BaseController {

    @Autowired
    private EmployeeService employeeService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation("查询员工列表")
    @ResponseBody
    public TableDataInfo queryList(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize){
        List<EmployeeDO> employeeDOList = employeeService.queryList(pageNum, pageSize);
        return getDataTable(employeeDOList);
    }

    /**
     * 新增员工
     *
     * @param employeeDTO 员工信息DTO
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation("新增员工")
    @ResponseBody
    public RestResult<Boolean> addEmployee(@RequestBody @Validated(CreateGroup.class) EmployeeDTO employeeDTO) {
        Boolean result = employeeService.addEmployee(employeeDTO);
        return RestResult.success(result);
    }

    /**
     * 删除员工
     *
     * @param employeeQuery 员工查询条件
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @ApiOperation("删除员工")
    @ResponseBody
    public RestResult<Boolean> deleteEmployee(@RequestBody @Validated(DeleteGroup.class) EmployeeQuery employeeQuery) {
        Boolean result = employeeService.deleteEmployee(employeeQuery);
        return RestResult.success(result);
    }

    /**
     * 更新员工信息
     *
     * @param employeeDTO 员工信息DTO
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation("更新员工信息")
    @ResponseBody
    public RestResult<Boolean> updateEmployee(@RequestBody @Validated(UpdateGroup.class) EmployeeDTO employeeDTO) {
        Boolean result = employeeService.updateEmployee(employeeDTO);
        return RestResult.success(result);
    }

    /**
     * 查询员工信息
     *
     * @param employeeQuery 员工查询条件
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ApiOperation("查询员工信息")
    public RestResult<EmployeeDO> getEmployeeInfo(@Validated(QueryGroup.class) EmployeeQuery employeeQuery) {
        EmployeeDO result = employeeService.getEmployeeInfo(employeeQuery);
        return RestResult.success(result);
    }

    /**
     * 生成课程表
     *
     * @param courseScheduleDTO 课程表信息DTO
     * @return
     */
    @RequestMapping(value = "/schedule/add", method = RequestMethod.POST)
    @ApiOperation("生成课程表")
    @ResponseBody
    public RestResult<Boolean> addCourseSchedule(@RequestBody @Validated(CreateGroup.class) CourseScheduleDTO courseScheduleDTO) {
        Boolean result = employeeService.addCourseSchedule(courseScheduleDTO);
        return RestResult.success(result);
    }

    /**
     * 删除课程表
     *
     * @param courseScheduleQuery 课程表查询条件
     * @return
     */
    @RequestMapping(value = "/schedule/delete", method = RequestMethod.DELETE)
    @ApiOperation("删除课程表")
    @ResponseBody
    public RestResult<Boolean> deleteCourseSchedule(@RequestBody @Validated(DeleteGroup.class) CourseScheduleQuery courseScheduleQuery) {
        Boolean result = employeeService.deleteCourseSchedule(courseScheduleQuery);
        return RestResult.success(result);
    }

    /**
     * 更新课程表
     *
     * @param courseScheduleDTO 课程表信息DTO
     * @return
     */
    @RequestMapping(value = "/schedule/update", method = RequestMethod.PUT)
    @ApiOperation("更新课程表")
    @ResponseBody
    public RestResult<Boolean> updateCourseSchedule(@RequestBody @Validated(UpdateGroup.class) CourseScheduleDTO courseScheduleDTO) {
        Boolean result = employeeService.updateCourseSchedule(courseScheduleDTO);
        return RestResult.success(result);
    }

    /**
     * 查询课程表
     *
     * @param courseScheduleQuery 课程表查询条件
     * @return
     */
    @RequestMapping(value = "/schedule/info", method = RequestMethod.GET)
    @ApiOperation("查询课程表")
    public RestResult<CourseScheduleDO> getCourseScheduleInfo(@Validated(QueryGroup.class) CourseScheduleQuery courseScheduleQuery) {
        CourseScheduleDO result = employeeService.getCourseScheduleInfo(courseScheduleQuery);
        return RestResult.success(result);
    }
}
